/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.utils;

import java.io.*;

/**
 *
 * @author pierrereimertz
 */
public class CopyFile {

    public static void copyFile(String fileUrl, String fileName) throws FileNotFoundException, IOException {
        try {

            File sourceFile = new File(fileUrl);
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(sourceFile), 1024);
            File targetFile = new File("database/pictures/" + fileName);
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(targetFile), 1024);
            int theChar;
            while ((theChar = bis.read()) != -1) {
                bos.write(theChar);
            }
            bos.close();
            bis.close();
        } catch (Exception ex) {
        }
    }
}
